//
//  UIAlertController+LQExtension.m
//  LQProductIntelligenceService
//
//  Created by Yim on 16/7/25.
//  Copyright © 2016年 张宁. All rights reserved.
//

#import "UIAlertController+LQExtension.h"


@implementation UIAlertController (LQExtension)

/**
 *  电话呼叫提示
 */
+ (instancetype) alertWithPhone:(NSString *)phone withWeb:(UIWebView *)webView
{
    NSString *strMessage = [NSString stringWithFormat:@"是否呼叫: %@",phone];
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:strMessage preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *call = [UIAlertAction actionWithTitle:@"呼叫" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
       
            NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",phone]];
            NSURLRequest *request = [NSURLRequest requestWithURL:url];
            [webView loadRequest:request];
    }];

    UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        //        MYNSLOG;
    }];
    [alert addAction:call];
    [alert addAction:cancel];
    return alert;
}
/**
 *  alert扩展
 */
+ (instancetype) alertWithTitle:(NSString *)title alertStyle:(UIAlertControllerStyle)style contentString:(NSString *)message andWithAction:(NSString *)universalStr andWithCancel:(NSString *)cancelStr
{
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:style];
    UIAlertAction *call = [UIAlertAction actionWithTitle:title style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        
    }];
    UIAlertAction *cancel = [UIAlertAction actionWithTitle:cancelStr style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        //        MYNSLOG;
    }];
    [alert addAction:call];
    [alert addAction:cancel];
    return alert;
}

+ (instancetype) alertWithTitle:(NSString *)title alertStyle:(UIAlertControllerStyle)style contentString:(NSString *)message andWithCancel:(NSString *)cancelStr
{
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:style];
    
    UIAlertAction *cancel = [UIAlertAction actionWithTitle:cancelStr style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        //        MYNSLOG;
    }];
    [alert addAction:cancel];
    return alert;
}

@end
